package main.java.dynamicProxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.util.Arrays;

public class DynamicProxyHandler implements InvocationHandler {
    private Object proxied;

    public DynamicProxyHandler(Object proxied) {
        this.proxied = proxied;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        System.out.println(" 动态代理---- proxy :"+proxy.getClass()+
                " , method :"+method+
                " , args :"+args);
        if(args!=null){
            Arrays.stream(args)
                    .forEach(e-> System.out.println("   "+e));
        }

        return method.invoke(proxied,args);
    }
}
